package com.my.ads.lib.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.my.ads.lib.Config;
import com.my.ads.lib.activity.WeatherActivity;
import com.my.ads.lib.utils.Utils;

import java.util.Calendar;

/**
 * Created by xuanyang on 2018/3/26.
 */

public class WeatherReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        Log.i(Config.TagLog, "weather");

        try {
            Calendar cal = Calendar.getInstance();
            int min = cal.get(Calendar.MINUTE);
            if (min == 0 || min == 15 || min == 30 || min == 45) {
//                        if (!TextUtils.isEmpty(WeatherUtils.getInstance().getWeatherJson(MainActivity.this))) { // 等待修正
                Utils.startActivity(context, WeatherActivity.class);
//                        }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
